package cn.sccl.dirms.topo.discovery.model;

import cn.sccl.common.exception.BusinessException;
import cn.sccl.common.model.BaseModel;

/**
* 自动发现规则
* 数据库表 T_TOPO_DISCOVER_RULE 的实体对象
* Created by _minus on 2017-09-22.
*/
public class DiscoverRule extends BaseModel{
   /**
   *表名
   */
   public final static String TABLE_NAME ="t_topo_discover_rule";

    private String name;//规则名称
    private String snmpCommunity;//snpm参数
    private String snmpVersion;//snpm参数
    private String startIp;//网段启端ip
    private String endIp;//网段终端ip

    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return this.name;
    }
    public void setSnmpCommunity(String snmpCommunity){
        this.snmpCommunity = snmpCommunity;
    }

    public String getSnmpCommunity(){
        return this.snmpCommunity;
    }
    public void setSnmpVersion(String snmpVersion){
        this.snmpVersion = snmpVersion;
    }

    public String getSnmpVersion(){
        return this.snmpVersion;
    }
    public void setStartIp(String startIp){
        this.startIp = startIp;
    }

    public String getStartIp(){
        return this.startIp;
    }
    public void setEndIp(String endIp){
        this.endIp = endIp;
    }

    public String getEndIp(){
        return this.endIp;
    }

    /**
    * clone一个对象。
    * @param cls 需要克隆的对象类型，只能是当前类的子类
    * @param <T>
    * @return
    * @throws IllegalAccessException
    * @throws InstantiationException
    */
    public <T extends DiscoverRule> T clone(Class<T> cls) {
       try {
          T t = cls.newInstance();
          t.setId(this.getId());
          t.setDeleteFlag(this.isDeleteFlag());
          t.setCreateTime(this.getCreateTime());
          t.setUpdateTime(this.getUpdateTime());
          t.setName(this.getName());
          t.setSnmpCommunity(this.getSnmpCommunity());
          t.setSnmpVersion(this.getSnmpVersion());
          t.setStartIp(this.getStartIp());
          t.setEndIp(this.getEndIp());
          /*t.setPosition(this.getPosition());
          t.setUpdateUser(this.getUpdateUser());
          t.setCreateUser(this.getCreateUser());*/
          return t;
       } catch (Exception e) {
          e.printStackTrace();
          throw new BusinessException("对象克隆失败，请克隆的目标对象是否具有无参的构造函数。", e.getCause());
       }
    }
}